package com.jungle.mogo.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.anwen.mongo.service.impl.ServiceImpl;
import com.jungle.mogo.entity.pojo.User;
import com.jungle.mogo.entity.vo.UserReqVO;
import com.jungle.mogo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author Jungle
 * @create 2024-05-21 17:26
 */
@Slf4j
@Service
public class UserServiceImpl extends ServiceImpl<User> implements UserService {

    @Override
    public Boolean add(UserReqVO userReqVO) {
        return save(BeanUtil.toBean(userReqVO, User.class));
        // List<User> list = LongStream.range(1, 10).mapToObj(num -> {
        //     User user = new User();
        //     user.setAge(RandomUtil.randomLong(10, 100));
        //     user.setName("张三" + num);
        //     user.setEmail(num + "@gmail.com");
        //     user.setDelFlag("0");
        //     return user;
        // }).toList();
        // Boolean b = saveBatch(list);
        // log.info("操作结果==>{}", b);
        // return b;
    }

    @Override
    public Boolean removeAll() {
        // return ;
        return false;
    }

    @Override
    public Boolean deleteById(Long id) {
        return removeById(id);
    }

    @Override
    public User getUserByName(String name) {
        return lambdaQuery().like(User::getName, name).one();
    }
}